package com.chixing.day12.day12_Homework;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class MyorderTest {
    public static void main(String[] args) {
        Customer cu1 = new Customer(101,"smith","15151518020","江苏省");

        LocalDateTime dateTime1 = LocalDateTime.of(2022, 9, 23, 10, 10, 45);
        LocalDateTime dateTime2 = LocalDateTime.of(2022, 4, 21, 8, 20, 45);
        LocalDateTime dateTime3 = LocalDateTime.of(2022, 4, 22, 15, 10, 45);

        MyOrder order1 = new MyOrder(321,"s185",182.45,dateTime1,cu1);
        MyOrder order2 = new MyOrder(322,"s186",371.45,dateTime2,cu1);
        MyOrder order3 = new MyOrder(323,"s187",246.56,dateTime3,cu1);

        //1
        List<MyOrder> orderList = new ArrayList<>();
         orderList.add(order1);
         orderList.add(order2);
         orderList.add(order3);
         System.out.println(orderList);

         //2
         double sum = 0;
         for (MyOrder TotalPrice : orderList){
             if(TotalPrice.getCustomer().getCustomerName() == "smith"){
                  sum += TotalPrice.getTotalPrice();
             }
         }
        System.out.println("总金额为: " + sum);

         //3

        LocalDateTime dateTime = LocalDateTime.of(2022,5,1,00,00,12);
        System.out.println(dateTime);
        System.out.println(dateTime1);
        System.out.println(dateTime.isBefore(dateTime1));
        for (MyOrder localDateTime : orderList){
             if(localDateTime.getCreateOrderTime().isBefore(dateTime)){
                 System.out.println(localDateTime);
             }
        }












    }

}
